﻿using System;
using System.Collections.Generic;
using System.Data.OracleClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Xiaov.SmartWeb.Infrastructure.ExtMethod;

namespace Xiaov.SmartWeb.Application.PluginSrc.StatisticalSystem
{
  public partial class ClearReport : System.Web.UI.Page
  {
    public string TableName { get; set; }
    public string Year { get; set; }
    public string Month { get; set; }
    public string DWBM { get; set; }
    public string ZBBM { get; set; }
    protected void Page_Load(object sender, EventArgs e)
    {
      TableName = Request.Form["tn"].ToRequestString();
      Year = Request.Form["year"].ToRequestString();
      Month = Request.Form["month"].ToRequestString();
      DWBM = Request.Form["dwbm"].ToRequestString();
      //Maticsoft.DBUtility.DbHelperOra.ExecuteSql("delete from " + TableName + " where DWBM='" + DWBM + "' and NF=" + Year + " and YF=" + Month + "");

      LoadProc("p_clear");
      LoadProc("p_createversion");
    }

    /// <summary>
    /// 调用存储过程
    /// </summary>
    /// <param name="ProcdureName">过程名称</param>
    /// <returns>返回值</returns>
    public bool LoadProc(string ProcdureName)
    {
      OracleParameter[] parameters ={
            new OracleParameter("v_bbbm",OracleType.VarChar,20),
　　     new OracleParameter("v_dwbm",OracleType.VarChar,20),
　　     new OracleParameter("v_nf",OracleType.Number,4),
            new OracleParameter("v_yf",OracleType.Number,2)
　　      };
      parameters[0].Value = TableName.ToUpper();
      parameters[1].Value = DWBM.ToUpper();
      parameters[2].Value = Year;
      parameters[3].Value = Month;
      try
      {
        OracleDataReader odr = Maticsoft.DBUtility.DbHelperOra.RunProcedure(ProcdureName, parameters);
        odr.Close();
        return true;
      }
      catch
      {
        return false;
      }
    }
  }
}